#ifndef __ATLCTRLS2_H__
#define __ATLCTRLS2_H__

#pragma  once


namespace WTL
{
	class CTabCtrlEx : public CTabCtrl
	{
	public:
		int FindItem(LPCTSTR lpszText, UINT nLength = -1)
		{
			ATLASSERT(NULL != m_hWnd);

			int nCount = this->GetItemCount();
			TCITEM tcItem = {0};

			tcItem.pszText = (LPTSTR)lpszText;
			if (-1 == nLength)
			{
				tcItem.cchTextMax = (int)_tcslen(lpszText);
			}else
			{
				tcItem.cchTextMax = nLength;
			}

			if (nCount >= 0)
			{
				for (int nItem=0; nItem<nCount; nItem++)
				{
					this->GetItem(nItem, &tcItem);
					if (StrCmpI(lpszText, tcItem.pszText) == 0)
					{
						return nItem;
					}
				}
			}

			return -1;
		}
	};

}; // end namespace WTL


#endif // end __ATLCTRLS2_H__
